var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "statisticsDate",
			name : "日期"
		}, {
			colkey : "warehouse",
			name : "仓位"
		}, {
			colkey : "material_code",
			name : "物料编码"
		}, {
			colkey : "cid",
			name : "客户编号"
		}, {
			colkey : "cname",
			name : "客户名称"
		}, {
			colkey : "unit",
			name : "单位"
		}, {
			colkey : "mold_code",
			name : "模具编码"
		}, {
			colkey : "length",
			name : "长"
		}, {
			colkey : "weight",
			name : "宽"
		}, {
			colkey : "height",
			name : "高"
		}, {
			colkey : "volume",
			name : "体积"
		}, {
			colkey : "commonCode",
			name : "通用件编码"
		}, {
			colkey : "client_weight",
			name : "重量"
		}, {
			colkey : "orderPack",
			name : "每包件数"
		}, {
			colkey : "matingCases",
			name : "配套件数"
		}, {
			colkey : "qualifiedCount",
			name : "合格品数量"
		}, {
			colkey : "abolishCount",
			name : "废品数量"
		}, {
			colkey : "sLabelPrint",
			name : "标签打印数"
		}, {
			colkey : "residuePack",
			name : "剩余包数"
		}, {
			colkey : "sStorageDay",
			name : "已入库天数",
			renderData : function(rowindex,data, rowdata, column) {
				if ((data>=0 &&data<=3) || (data>="0" && data<="3")){
					return data;
				}else if ((data>=4 &&data<=7) || (data>="4" && data<="7")){
					return "<font color='lightgreen'>"+data+"</font>";
				}else if ((data>=8 &&data<=15) || (data>="8" && data<="15")){
					return "<font color='orange'>"+data+"</font>";
				}else if ((data>=16 &&data<=30) || (data>="16" && data<="30")){
					return "<font color='brown'>"+data+"</font>";
				}else if ((data>=31 &&data<=90) || (data>="31" && data<="90")){
					return "<font color='blue'>"+data+"</font>";
				}else if (data>90){
					return "<font color='red'>"+data+"</font>";
				}else{
					return "未入库";
				}
			}
		}, {
			colkey : "remark",
			name : "备注"
		} ],
		jsonUrl : rootPath
				+ '/returnproduct_statistics/returnproduct_statistics_findByPage.shtml',
		dymCol : true,
		checkbox : true,
		serNumber : false
	});
	$("#addFun").click("click", function() {
		addAccount();
	});
	$("#editFun").click("click", function() {
		editAccount();
	});
	$("#delFun").click("click", function() {
		delAccount();
	});
	$("#search").click("click", function() {//  绑定查询按扭

		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});

});
function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer
			.open({
				title : "编辑退货产品入库数量统计表",
				type : 2,
				area : [ "800px", "100%" ],
				content : rootPath
						+ '/returnproduct_statistics/returnproduct_statistics_edit.shtml?id='
						+ cbox
			});
}

